package com.bj58.groupbuy.action.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.bj58.groupbuy.action.db.CommonDao;
import com.bj58.groupbuy.action.db.DBConfig;
import com.bj58.groupbuy.action.model.AllianceBillingMetrics;
import com.bj58.groupbuy.action.model.ZSClickInfo;
import com.bj58.groupbuy.action.service.DataWebIFService;

public class DataWebIFServiceImpl implements DataWebIFService {
	private CommonDao comDao = new CommonDao();
	
	@Override
	public List<AllianceBillingMetrics> getAllianceCate(String beginDate,
			String endDate) throws Exception {
		
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT statDate,cate1,sum(amount) FROM `alliance_billing_metrics` ");
		sql.append("where cate1 in('房屋','跳蚤','车辆','招聘','黄页','宠物') ");
		sql.append("and statDate >='"+beginDate+"' and statDate<='"+endDate+"' ");
		sql.append("group by statDate,cate1 ");

		List<String>  cols = new ArrayList<String>();
		cols.add("statDate");
		cols.add("cate1");
		cols.add("amount");
		
		return comDao.getCommonStatList(sql.toString(), cols, AllianceBillingMetrics.class, DBConfig.db_68_ors.getIntType());
	}

	@Override
	public List<ZSClickInfo> getZSclickinfo(String beginDate, String endDate)
			throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT stat_date,cooperator,pc,count(1)   ");
		sql.append(" FROM zs_click_info ");
		sql.append(" where stat_date >='"+beginDate+"' and stat_date<='"+endDate+"' and cooperator !='' and cooperator is not null and cooperator != 'null'");
		sql.append(" group by stat_date,cooperator,pc ");

		List<String>  cols = new ArrayList<String>();
		cols.add("stat_date");
		cols.add("lottery_name");
		cols.add("pay_order_count");
		cols.add("order_count");
		
		return comDao.getCommonStatList(sql.toString(), cols, ZSClickInfo.class, DBConfig.db_68_ors.getIntType());
	
	}
	
}
